import React, { memo, useState } from "react";
import GoodsListModal from "./GoodsListModal";

import { Button } from "antd";

const ApplyMemberPrice = ({
	type = "primary",
	text = "申请会员价",
	selectedIds = [],
	selectedSkuCodes = [],
	tableRef,
	onSubmitSuccess
}) => {
	const [show, toggleShow] = useState(false);
	const modalProps = {
		handleCancel() {
			toggleShow(false);
		},
		onGoodsSkuListSelected(values) {},
		destroyOnClose: true,
		selectedIds,
		selectedSkuCodes,
		onSubmitSuccess
	};

	return (
		<>
			<Button type={type} onClick={() => toggleShow(true)}>
				{text}
			</Button>
			{show ? <GoodsListModal ref={tableRef} {...modalProps} /> : null}
		</>
	);
};
export default memo(ApplyMemberPrice);
